|
|
|
|
|
|
|
Figure 17.8
A high-resolution ray-traced image. |
|
|
|
 |
|
|
|
|
If skip < 2 Then ' Get the picture box's pixels. GetBitmapPixels pic, pixels, bits_per_pixel
End If
' Get the transformed coordinates of the eye. xoff = pic.ScaleWidth / 2
yoff = pic.ScaleHeight / 2
Xmin = pic.ScaleLeft
Xmax = Xmin + pic.ScaleWidth - 1
Ymin = pic.ScaleTop
Ymax = Ymin + pic.ScaleHeight - 1
For pix_y = Ymin To Ymax Step skip
real_y = pix_y - yoff
For pix_x = Xmin To Xmax Step skip
real_x = pix_x - xoff ' Calculate the value of pixel (x, y).
' After transformation the eye is
' at (0, 0, EyeR) and the plane of
' projection lies in the X-Y plane. TraceRay True, depth, Nothing, _
0, 0, EyeR, _
CSng(real_x), CSng(real_y), -EyeR, _
R, G, B
' Draw the pixel. If skip < 2 Then ' Save the pixel value. With pixels(pix_x, pix_y)
.rgbRed = R
.rgbGreen = G
.rgbBlue = B |
|
|
|
|
|